Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the CameraShutter-related logic on UX5406 #3359

Merged
merged 1 commit into from
Nov 10, 2024

Conversation

yinyue200
Copy link
Contributor

@yinyue200 yinyue200 commented Nov 10, 2024

I apologize that my initial PR (#3358 ) did not correctly implement this feature. Initially, although I disabled Secure Boot and used tools like IRPMon to monitor ACPI messages sent by MyASUS, I found that the same DSTS message was sent regardless of whether the Camera was turned on or off. I assumed there was an issue with my monitoring setup, so I looked up asus-shutter-linux on GitHub and referenced that project to implement the relevant logic.

In my environment, OSD is disabled, and I did not run Visual Studio with administrator privileges. Under these conditions, the related keys functioned as expected following the logic from asus-shutter-linux. However, after running the 'scan' function, I noticed that on my machine (which differs from the model indicated in asus-shutter-linux), the return values were '262144' or '262145' rather than '0' or '1'.

After some testing, I found that for the CameraToggle to work correctly, a corresponding DSTS message must be sent after pressing it. On my machine, the DEVS message is unnecessary, as sending it alone does not change the CameraShutter state (which makes sense, as it should not allow unauthorized activation of the camera). This version should now correctly implement the feature and is ready for merging.

@seerge
Copy link
Owner

seerge commented Nov 10, 2024

@yinyue200 262144 and 262145 is same 0 and 1, just with (one more) status bit on 19th place
https://www.rapidtables.com/convert/number/decimal-to-binary.html?x=262145

So to actually "read" shutter status you can just do cameraShutter & 1 (if i get the logic)

I didn't completely get your explanation tho. Does it mean that there is no need to set any value to 0x00060078 at all ? How does it toggle it then?

@yinyue200
Copy link
Contributor Author

Yes, a DSTS message must be sent to read the status in order to toggle the Camera key; no additional DEVS messages are required. A standalone DSTS message will not work; the user must have recently pressed the corresponding physical key.

@seerge
Copy link
Owner

seerge commented Nov 10, 2024

@yinyue200 yes, DSTS only reads status. But how to toggle camera shutter ON and OFF then ? If application is not send any command for what, who does?

@yinyue200
Copy link
Contributor Author

My understanding is that, on my device, the logic for the camera shutter is implemented by the firmware. No software can send a message to toggle its status. However, when the corresponding camera shutter button is pressed, the software must initiate a DSTS message within a certain time to enable the logic in the firmware. ASUS designed it this way so that software cannot toggle the camera shutter status, thereby avoiding some security risks. I’m not sure if earlier machines have similar logic, but that’s how it works on my machine.

@seerge
Copy link
Owner

seerge commented Nov 10, 2024

@yinyue200 ah, ok, interesting and makes sense. Are you sure that it's not just working by itself on hardware level (i.e. w/o calling DSTS) ?

Then I also wonder if this part is even needed

            if (cameraShutter == 0)
            {
                Program.acpi.DeviceSet(AsusACPI.CameraShutter, 1, "CameraShutterOn");
                Program.toast.RunToast($"Camera Off");
            }
            else if (cameraShutter == 1)
            {
                Program.acpi.DeviceSet(AsusACPI.CameraShutter, 0, "CameraShutterOff");
                Program.toast.RunToast($"Camera On");
            }

As I'm not sure if other devices behave differently then.

@yinyue200
Copy link
Contributor Author

@yinyue200 262144 and 262145 is same 0 and 1, just with (one more) status bit on 19th place https://www.rapidtables.com/convert/number/decimal-to-binary.html?x=262145

So to actually "read" shutter status you can just do cameraShutter & 1 (if i get the logic)

I didn't completely get your explanation tho. Does it mean that there is no need to set any value to 0x00060078 at all ? How does it toggle it then?

Yes, but it seems that in asus_shutter.c, it simply uses 1 and 0 rather than shifting 1 and 0 by specific bit positions. Therefore, I suspect that slightly earlier machines (or firmware?) required a DEVS message to toggle the CameraShutter status.

@seerge
Copy link
Owner

seerge commented Nov 10, 2024

@yinyue200 ok, then lets keep both response variants, and keep them separate.

Thanks, and merged.

@seerge seerge merged commit 468ed27 into seerge:main Nov 10, 2024
3 checks passed
@yinyue200
Copy link
Contributor Author

@yinyue200 ah, ok, interesting and makes sense. Are you sure that it's not just working by itself on hardware level (i.e. w/o calling DSTS) ?

Then I also wonder if this part is even needed

            if (cameraShutter == 0)
            {
                Program.acpi.DeviceSet(AsusACPI.CameraShutter, 1, "CameraShutterOn");
                Program.toast.RunToast($"Camera Off");
            }
            else if (cameraShutter == 1)
            {
                Program.acpi.DeviceSet(AsusACPI.CameraShutter, 0, "CameraShutterOff");
                Program.toast.RunToast($"Camera On");
            }

As I'm not sure if other devices behave differently then.

To add a bit more information, I've tested many times on my machine, and if there is no DSTS message, the key still retains its primary function (prevent the camera on) . However, the CameraShutter LED indicator on the keyboard will remain off (if there are DSTS messages it works fine). When the camera is in use, though, its status can be indirectly observed through the camera indicator light.

It’s also possible that this is just a bug in the current firmware. But we don't have the documentation.

@yinyue200 yinyue200 deleted the fixCameraShutter branch November 10, 2024 22:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants